package org.hxyjs.controller;

import org.hxyjs.dto.DTO;
import org.hxyjs.entity.Advertisingtype;
import org.hxyjs.entity.Advertisingtype;
import org.hxyjs.page.PageInfo;
import org.hxyjs.service.AdvertisingtypeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@Controller
@RequestMapping("/advertisingtypeController")
public class AdvertisingtypeController {
	@Resource
	AdvertisingtypeService advertisingtypeService;
	@RequestMapping("/getAllAdvertisingtype")
	@ResponseBody //把方法的返回值按json转换之后 输出到浏览器
    public DTO<Advertisingtype> getAllAdvertisingtype() throws Exception {
    	System.out.println("查询全部广告类型");
		return advertisingtypeService.getAllAdvertisingtypes();
    }

	@RequestMapping("/deleteAdvertisingtypeByAdvrno/{advrno}")
	@ResponseBody
    public DTO<Advertisingtype> deleteAdvertisingtypeByAdvrno(@PathVariable("advrno") String advrno) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
    	System.out.println(advrno+"删除广告类型");
    	return advertisingtypeService.deleteAdvertisingtypeByAdvrno(advrno);
    }

	@RequestMapping("/updateAdvertisingtypeByAdvrno")
	@ResponseBody
	public DTO<Advertisingtype> updateAdvertisingtypeByAdvrno(@RequestBody Advertisingtype advertisingtype) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("修改广告类型");
		return advertisingtypeService.updateAdvertisingtypeByAdvrno(advertisingtype);
	}


	@RequestMapping("/addAdvertisingtype")
	@ResponseBody
	public DTO<Advertisingtype> addAdvertisingtype(@RequestBody Advertisingtype advertisingtype) throws Exception {//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("增加广告类型");
		System.out.println(advertisingtype);
 		return advertisingtypeService.addAdvertisingtype(advertisingtype);
	}
	@RequestMapping("/getAdvertisingtypeByPage")
	@ResponseBody
	public DTO<Advertisingtype> getAdvertisingtypeByPage(PageInfo pageInfo) throws Exception{//如何从页面传入参数到方法 用这个注解绑定变量@PathVariable
		System.out.println("分页广告类型");
		return advertisingtypeService.getAdvertisingtypeByPage(pageInfo);
	}

}